<?php echo $this->element('displayHeader'); ?>
<?php echo $ajax->form('Warehouse', 'post', array('update'=>'content', 'indicator' => 'indicator', 'url'=>array('action'=>'save'))); ?>

<div class="toolbar">
    <div id="tLeft">
        <?php if ($mode == 'add') : ?>
        <?php echo $this->element('toolbar', array('buttons' => array('save', 'clear', 'back'))); ?>
        <?php else : // mode edit ?>
        <?php echo $this->element('toolbar', array('buttons' => array('save', 'add', 'refresh_view',
                    array('delete' => array('model' => 'Warehouse', 'title' => 'name')), 'back'))); ?>
        <?php endif; ?>
    </div>
    <div id="tRight"><?php echo $this->element('neighbors', array('model' => 'Warehouse', 'title' => 'name')); ?></div>
</div>

<?php echo $form->input('Warehouse.id'); ?>
<fieldset>
    <legend>General Information</legend>
    <table style="width: 600px">
        <tbody>
            <tr>
                <td width="130px"><?php echo $form->label('Warehouse.name', 'Name', array('class' => 'required')) ?></td>
                <td colspan="3"><?php echo $form->text("Warehouse.name", array('class' => 'wide')) ?> </td>
            </tr>
            <tr>
                <td class="top"><?php echo $form->label("Warehouse.address", 'Address') ?></td>
                <td colspan="3"><?php echo $form->textarea('Warehouse.address', array('rows' => 2, 'cols' => 50, 'class' => 'wide')) ?></td>
            </tr>
            <tr>
                <td><?php echo $form->label("Warehouse.province_id", 'Province') ?></td>
                <td width="200px"><?php echo $form->select("Warehouse.province_id", $provinces) ?> </td>
                <td width="100px"><?php echo $form->label("Warehouse.zipcode", 'Zipcode') ?></td>
                <td><?php echo $form->text("Warehouse.zipcode", array('size'=>5,'maxlength'=>5)) ?></td>
            </tr>
            <tr>
                <td><?php echo $form->label("Warehouse.tel", 'Tel.') ?></td>
                <td><?php echo $form->text("Warehouse.tel") ?></td>
                <td><?php echo $form->label("Warehouse.fax", 'Fax') ?></td>
                <td><?php echo $form->text("Warehouse.fax") ?></td>
            </tr>
        </tbody>
    </table>
</fieldset>
<?php echo $form->end(); ?>

<fieldset>
    <legend>Location Information</legend>
    <?php if ($mode == 'edit') : ?>
    <div id="divLocations">
        <?php echo $this->requestAction('warehouses/display_locations/' . $this->data['Warehouse']['id'], array('return')); ?>
    </div>
    <?php else : ?>
    <div class="caption">Please select a warehouse first.</div>
    <?php endif; ?>
</fieldset>